Fix translation of read_image* built-ins to SPIR-V#408
Conversation
| if (OC == OpImageRead) { | ||
| // There are several read_image* functions defined by OpenCL C spec, but | ||
| // all of them use the same SPIR-V Instruction - some of them might only | ||
| // differ by return type, so, we need to include return type into the |
There was a problem hiding this comment.
Including the return type in the mangled name does not sound like the correct way to handle this issue.
SPIR-V 1.4 adds the SignExtend and ZeroExtend image operands. It would be better to make use of those somehow.
We have a downstream patch that uses a single bit in the image operands to disambiguate. I could try to upstream that instead if you are interested, but it will require a bit of rework and it will not be conformant to any pre-1.4 spec.
There was a problem hiding this comment.
We also should disambiguate between the following 2 function calls:
uint4 c = read_imageui(input, (int4)(0, 0, 0, 0));
float4 f = read_imagef(input, (int4)(0, 0, 0, 0));
I don't think the image operands can help to represent these calls in SPIR-V-friendly LLVM IR.
There was a problem hiding this comment.
Ah sorry, I didn't realize this was only about the SPIR-V representation in LLVM IR.
LGTM then!
| if (OC == OpImageRead) { | ||
| // There are several read_image* functions defined by OpenCL C spec, but | ||
| // all of them use the same SPIR-V Instruction - some of them might only | ||
| // differ by return type, so, we need to include return type into the |
There was a problem hiding this comment.
Ah sorry, I didn't realize this was only about the SPIR-V representation in LLVM IR.
LGTM then!
There are several overloads of read_image function defined by OpenCL C spec, but all of them use the same SPIR-V instruction, so, we need to add one more optional postfix to differentiate instructions with the same argument types, but different return types. Example: - int4 read_imagei(image2d_t, sampler_t, int2) - float4 read_imagef(image2d_t, sampler_t, int2) Both functions above are represented by the same SPIR-V instruction and we need to distinguish them in SPIR-V friendly LLVM IR.
1be672f to
51808d4
Compare
There are several overloads of read_image function defined by OpenCL C
spec, but all of them use the same SPIR-V instruction, so, we need to
add one more optional postfix to differentiate instructions with the
same argument types, but different return types.
Example:
Both functions above are represented by the same SPIR-V instruction and
we need to distinguish them in SPIR-V friendly LLVM IR.